package com.cgah

import java.text.SimpleDateFormat
import java.text.DecimalFormat
import java.text.NumberFormat

/**
 * Created by IntelliJ IDEA.
 * User: chue
 * Date: 4/17/11
 * Time: 6:13 PM
 * To change this template use File | Settings | File Templates.
 */

/**
 'cause with all it's bragging, groovy date handling still SUX!
 see http://groovy.codehaus.org/JN0545-Dates
 really? this is an improvement, i don't think so!
 hey look, java gave you 1 million ways to do it, now we are giving you 2 million ways! YEAH BABY
 */
class DateNumberFormatter {
    static SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATE_TIME_FORMAT);
    static NumberFormat numf = new DecimalFormat(Constants.TWO_DECIMAL_NUMBER_FORMAT);

    static String formatDate(Date d) {
        return d != null ? sdf.format(d) : "";
    }

    static String formatNumber(Number n) {
        // don't konw if this is necessary but what ever.
        if (null == n) return "";

        BigDecimal bd = new BigDecimal(n.doubleValue()/1.00000000d);
        return numf.format(bd);
    }


}
